#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Unit.h>
#include <Metrology.h>
#include <Length.h>
#include <FormatOutput.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(LengthDisplay)
{
    TEST( 1 mile should be displayed to 5280 feet)
    {
        std::ostringstream buf;
        Length(1, MILE).output(buf, BASICUNITOUTPUT);
        ASSERT_TRUE(buf.str() == "5280 feet");
    }

    TEST( 2 yard should be displayed to 6 feet)
    {
        std::ostringstream buf;
        Length(2, YARD).output(buf, BASICUNITOUTPUT);
        ASSERT_TRUE(buf.str() == "6 feet");
    }


    TEST( 0 mile should be displayed to 0 feet)
    {
        std::ostringstream buf;
        Length(0, MILE).output(buf, BASICUNITOUTPUT);
        ASSERT_TRUE(buf.str() == "0 feet");
    }

    TEST( 3 mile should be displayed to 3 mile)
    {
        std::ostringstream buf;
        Length(3, MILE).output(buf, STDOUTPUT);
        ASSERT_TRUE(buf.str() == "3 mile");
    }
   
    TEST( 1768 yard should be displayed to 1 mile 8 yard)
    {
        std::ostringstream buf;
        Length(1768, YARD).output(buf, STDOUTPUT);
        ASSERT_TRUE(buf.str() == "1 mile 8 yard");
    }


    TEST( 5288 feet should be displayed to 1 mile 2 yard 2 feet)
    {
        std::ostringstream buf;
        Length(5288, FEET).output(buf, STDOUTPUT);
        ASSERT_TRUE(buf.str() == "1 mile 2 yard 2 feet"); 
    }


};


FIXTURE(LengthCompare)
{

    TEST(1 mile should be equal to 1760 yard)
    {
        Length mile(1, MILE);
        Length yard(1760, YARD);
        ASSERT_TRUE(mile == yard);
    }

    TEST(1 mile should be not equal to 1761 yard)
    {
        Length mile(1, MILE);
        Length yard(1761, YARD);
        ASSERT_TRUE(mile != yard);
    }
    
    TEST(1 yard should be equal to 3 feet)
    {
        Length feet(3, FEET);
        Length yard(1, YARD);
        ASSERT_TRUE(feet == yard);
    }
    
    TEST(2 yard should be not equal to 7 feet)
    {
        Length feet(7, FEET);
        Length yard(2, YARD);
        ASSERT_TRUE(feet != yard);
    }
 

    TEST(1 mile should be equal to 5280 feet)
    {
        Length feet(5280, FEET);
        Length mile(1, MILE);
        ASSERT_TRUE(feet == mile);
    }

    TEST(1 mile should be not equal to 5279 feet)
    {
        Length feet(5279, FEET);
        Length mile(1, MILE);
        ASSERT_TRUE(feet != mile);
    }


};

FIXTURE(LengthCalc)
{
    TEST(1 mile == 1750 yard + 30 feet)
    {
        Length yard(1750, YARD);
        Length feet(30, FEET);
        Length mile(1, MILE);
        
        ASSERT_TRUE(mile == (yard + feet));
    }

    TEST(5345 feet == 1 mile + 20 yard + 5 feet)
    {
        Length yard(20, YARD);
        Length mile(1, MILE);
        Length feetA(5, FEET);
        Length feetB(5345, FEET);

        ASSERT_TRUE(feetB == (mile + yard + feetA));
    }

    
    TEST(2 mile != 1 mile + 20 yard)
    {
        Length yard(20, YARD);
        Length mileA(1, MILE);
        Length mileB(2, MILE);

        ASSERT_TRUE(mileB != (mileA + yard));
    }


};



FIXTURE(Mile)
{
    TEST(3 mile should be equal to 3 mile)
    {
        Length mileA(3, MILE);
        Length mileB(3, MILE);
        ASSERT_TRUE(mileA == mileB);
    }

    TEST(3 mile should be not equal to 4 mile)
    {
        Length mileA(3, MILE);
        Length mileB(4, MILE);
        ASSERT_TRUE(mileA != mileB);
    }

};

FIXTURE(Yard)
{
    TEST(3 yard should be equal to 3 yard)
    {
        Length yardA(3, YARD);
        Length yardB(3, YARD);
        ASSERT_TRUE(yardA == yardB);
    }

    TEST(3 yard should be not equal to 4 yard)
    {
        Length yardA(3, YARD);
        Length yardB(4, YARD);
        ASSERT_TRUE(yardA != yardB);
    }

};

FIXTURE(Feet)
{
    TEST(3 feet should be equal to 3 feet)
    {
        Length feetA(3, FEET);
        Length feetB(3, FEET);
        ASSERT_TRUE(feetA == feetB);
    }

    TEST(3 feet should be not equal to 4 feet)
    {
        Length feetA(4, FEET);
        Length feetB(3, FEET);
        ASSERT_TRUE(feetA != feetB);
    
    }

};

